#include<iostream>
#include<string>
const int N = 1e6 + 10;
int a[26],mp[N],kind;
using namespace std;
int main()
{
	string s;cin >> s;
	int len = s.size();
	int left = 0, right = 0,ret = len;
	while (right < len)
	{
		if (a[s[right] - 'a']++ == 0) kind++;
		while (kind == 26)
		{
			ret = min(ret,right - left + 1);
			if (a[s[left] - 'a']-- == 1) kind--;
			left++;
		}
		right++;
	}
	cout << ret << endl;
	return 0;
}